package com.oo.array_$.case_2;

import java.util.Scanner;

/**
 * NumDemo--编写JAVA程序，实现使用数组保存用户输入的5个
 * 数字，输出数组中下标为奇数的数组成员，
 * 并统计输入数据中偶数的个数
 *
 * @author: Jovi
 * @createTime: 2017-05-11 16:21
 **/
public class NumDemo {
    public static void main(String[] args) {
        int[] a = new int[5];
        Scanner sc = new Scanner(System.in);
        int count = 0;
        System.out.println("Please enter 5 numbers：");
        for (int i = 0; i < a.length; i++) {
            a[i]=sc.nextInt();
            if (a[i] % 2 == 0) {
                count++;
            }
        }
        System.out.println("================");
        System.out.println("The subscript for odd numbers which in the array is ：");
        for (int i = 0; i < a.length; i++) {
            if (!(i % 2 == 0)) {
                System.out.println("a[" + i + "]=" + a[i]);
            }
        }
        System.out.println("A total of "+count+"even numbers");
    }
}
